

#import "FAMMineTableHeaderView.h"
@interface FAMMineTableHeaderView()
@property (weak, nonatomic) IBOutlet UIImageView *FAMHeadImageView;
@property (weak, nonatomic) IBOutlet UILabel *FAMUserIdLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMTrackDietLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMHealthyEatLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMWeightLossLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMCurrentWeightLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMKcalLabel;

@end
@implementation FAMMineTableHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"FAMMineTableHeaderView" owner:self options:nil];
        self = array.firstObject;
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 400);
}
- (IBAction)FAM_weeklyDeficitTapClick:(UITapGestureRecognizer *)sender {
    [UIWindow.currentViewController.navigationController pushViewController:[FAMMineDeficitViewController new] animated:YES];
}

- (IBAction)FAM_currentWeightTapClick:(UITapGestureRecognizer *)sender {
    [UIWindow.currentViewController.navigationController pushViewController:[FAMMineWeightViewController new] animated:YES];
}
- (void)setFAMUserModel:(FAMGetFoodmateUserdataModel *)FAMUserModel {
    if ([FAMUserModel.gender isEqualToString:@"1"]) {
        self.FAMHeadImageView.image = [UIImage imageNamed:@"mine_male"];
    }else{
        self.FAMHeadImageView.image = [UIImage imageNamed:@"mine_female"];
    }
    self.FAMUserIdLabel.text = [NSString stringWithFormat:@"AdUser %@",FAMUserModel.user_id];
    self.FAMTrackDietLabel.text = FAMUserModel.statistics.record_count;
    self.FAMHealthyEatLabel.text = FAMUserModel.statistics.heathy_count;
    self.FAMWeightLossLabel.text = FAMUserModel.statistics.loss_weight;
    
    self.FAMCurrentWeightLabel.attributedText = [FAMTool FAM_AttributedString:FAMUserModel.weight styleTwoString:@"kg" styleColorOne:kCustom0xColor(0x202020, 1.0) styleColorTwo:kCustom0xColor(0x757575, 1.0) styleFontOne:20 styleFontTwo:16];
    
}
- (void)setFAMStatisticsModel:(FAMFoodmateStatisticsModel *)FAMStatisticsModel{
    CGFloat TotalCalories = 0;
    for (int i = 0; i < FAMStatisticsModel.cateList.count; i++) {
        CGFloat calories = ((FAMFoodmateStatisticsModel *)FAMStatisticsModel.cateList[i]).cate.calories.floatValue;
        TotalCalories += calories;
    }
    self.FAMKcalLabel.attributedText = [FAMTool FAM_AttributedString:[NSString stringWithFormat:@"%0.1f",TotalCalories] styleTwoString:@"kcal" styleColorOne:kCustom0xColor(0x202020, 1.0) styleColorTwo:kCustom0xColor(0x757575, 1.0) styleFontOne:20 styleFontTwo:16];
}
@end
